<template>
  <div>
    <router-view />
  </div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

// 组件挂载时检查登录状态
onMounted(() => {
  // 如果已经登录，重定向到数据统计页，否则跳转登录页
  const isLoggedIn = localStorage.getItem('isLoggedIn') === 'true'
  if (!isLoggedIn && router.currentRoute.value.path !== '/login') {
    router.push('/login')
  } else if (isLoggedIn && router.currentRoute.value.path === '/') {
    router.push('/data-analytics')
  }
})
</script>

<style>
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
</style> 